<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>校园宿舍管理系统 - 编辑宿舍</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color: #17a589;">
  <div class="container">
    <a class="navbar-brand" href="#">校园宿舍管理系统</a>
    <div class="collapse navbar-collapse">
      <ul class="navbar-nav me-auto">
        <li class="nav-item">
          <a class="nav-link" th:href="@{/home}">首页</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" th:href="@{/student/list}">学生管理</a>
        </li>
        <li class="nav-item">
          <a class="nav-link active" th:href="@{/dormitory/list}">宿舍管理</a>
        </li>
      </ul>
      <div class="d-flex">
        <span class="navbar-text me-3" th:text="'欢迎，' + ${session.user.username}"></span>
        <a class="btn btn-outline-light" th:href="@{/user/logout}">退出</a>
      </div>
    </div>
  </div>
</nav>
<div class="container mt-4">
  <div class="row">
    <div class="col-md-6 mx-auto">
      <div class="card">
        <div class="card-header">
          <h4>编辑宿舍</h4>
        </div>
        <div class="card-body">
          <form th:action="@{/dormitory/edit}" method="post">
            <input type="hidden" name="id" th:value="${dormitory.id}">
            <div class="mb-3">
              <label for="dormitoryNumber" class="form-label">宿舍号</label>
              <input type="text" class="form-control" id="dormitoryNumber" name="dormitoryNumber" th:value="${dormitory.dormitoryNumber}" required>
            </div>
            <div class="mb-3">
              <label for="building" class="form-label">宿舍楼</label>
              <input type="text" class="form-control" id="building" name="building" th:value="${dormitory.building}" required>
            </div>
            <div class="mb-3">
              <label for="floor" class="form-label">楼层</label>
              <input type="number" class="form-control" id="floor" name="floor" th:value="${dormitory.floor}" required>
            </div>
            <div class="mb-3">
              <label for="type" class="form-label">宿舍类型</label>
              <input type="text" class="form-control" id="type" name="type" th:value="${dormitory.type}" required>
              <div class="form-text">例如: 四人间, 二人间</div>
            </div>
            <div class="mb-3">
              <label for="capacity" class="form-label">容量</label>
              <input type="number" class="form-control" id="capacity" name="capacity" th:value="${dormitory.capacity}" required>
              <div class="form-text">该宿舍最多可入住人数</div>
            </div>
            <div class="mb-3">
              <label for="occupied" class="form-label">已入住人数</label>
              <input type="number" class="form-control" id="occupied" name="occupied" th:value="${dormitory.occupied}" required readonly>
              <div class="form-text">该字段由系统自动维护，请勿修改</div>
            </div>
            <div class="mb-3">
              <label for="status" class="form-label">状态</label>
              <input type="text" class="form-control" id="status" name="status" th:value="${dormitory.status}" required readonly>
              <div class="form-text">该字段由系统自动维护，请勿修改</div>
            </div>
            <button type="submit" class="btn btn-primary">保存</button>
            <a th:href="@{/dormitory/list}" class="btn btn-secondary">取消</a>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
</body>
</html>